home *** CD-ROM | disk | FTP | other *** search
/ Shareware Super Platinum 8 / Shareware Super Platinum 8.iso / mac / WIN_VB / VB_7DAYS.ZIP;1 / OPENFILE.BAS < prev    next >
Encoding:
BASIC Source File  |  1993-02-17  |  1.5 KB  |  54 lines

  1. USING OPENFILE
  2.  
  3. ' Here's how to use the API's OpenFile function to access
  4. ' undocumented data and time stamp data.
  5.  
  6. DefInt A-Z
  7.  
  8. Declare Function OpenFile Lib "Kernel" (ByVal lpFileName As String, lpReOpenBuff As OFSTRUCT, ByVal wStyle As Integer) As Integer
  9.  
  10. Global Const OF_EXIST = &H4000
  11. Global Const HFILE_ERROR = -1
  12.  
  13. Type OFSTRUCT
  14.   cBytes As String * 1        ' Length of structure
  15.   fFixedDisk As String * 1    ' 0 if on removable disk
  16.   nErrCode As Integer         ' MS-DOS error code
  17.   FileDate As String * 2      ' Reserved field
  18.   FileTime As String * 2      ' Reserved field
  19.   szPathName As String * 128  ' Complete pathname
  20. End Type
  21.  
  22.  
  23. Dim OFS As OFSTRUCT
  24.  
  25. Sub Command1_Click ()
  26.   FileName$ = Text1.Text
  27.   OFS.cBytes = Chr$(Len(OFS))
  28.   wStyle% = OF_EXIST
  29.   Result% = OpenFile(FileName$, OFS, wStyle%)
  30.   If Result% = HFILE_ERROR Then
  31.     Beep
  32.     MsgBox "Error: #" + Str$(OFS.nErrCode)
  33.     Exit Sub
  34.   End If
  35.  
  36. ' Parse Time value
  37.   TimeVal& = Asc(Right$(OFS.FileTime, 1)) * 256& + Asc(Left$(OFS.FileTime, 1))
  38.   Sec% = (TimeVal& And &H1F) * 2
  39.   Min% = (TimeVal& And &H7E0) \ &H20
  40.   Hr% = (TimeVal& And &HF800) \ &H800
  41.   TimeStr$ = Str$(Hr%) + ":" + Str$(Min%) + ":" + Str$(Sec%)
  42.  
  43. ' Parse Date value
  44.   DateVal& = Asc(Right$(OFS.FileDate, 1)) * 256& + Asc(Left$(OFS.FileDate, 1))
  45.   D% = (DateVal& And &H1F)
  46.   M% = (DateVal& And &H1E0) \ &H20
  47.   Y% = (DateVal& And &HFE00) \ &H200
  48.   DateStr$ = Str$(M%) + "/" + Str$(D%) + "/" + Str$(Y% + 1980)
  49.  
  50.   Text2.Text = TimeStr$ + "  " + DateStr$
  51.  
  52. End Sub
  53.  
  54.